package one.stand.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import one.stand.aop.ApiController;
import one.stand.model.ResultModel;
import one.stand.request.*;
import one.stand.response.CompanyRecruitResponse;
import one.stand.response.DynamicResponse;
import one.stand.response.UserCommonResponse;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 个人中心
 * @author Administrator
 */
@RestController
@RequestMapping("userApi/personal")
@Api(description = "个人中心")
public class PersonalController extends BaseController {

    @PostMapping("/addAddress")
    @ApiOperation(value = "添加我的地址")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "locationAddress", value = "定位地址", required = true, paramType = "String"),
            @ApiImplicitParam(name = "detailedAddress", value = "详细地址", required = true, paramType = "String"),
            @ApiImplicitParam(name = "sort", value = "排序", required = false, paramType = "Integer"),
            @ApiImplicitParam(name = "receiveName", value = "收货人名字", required = true, paramType = "String"),
            @ApiImplicitParam(name = "receivePhone", value = "收货人手机", required = true, paramType = "Integer"),
    })
    @ApiController(isLogin = true,paramClass =AddressRequest.class )
    public ResultModel addAddress(@RequestAttribute AddressRequest request) {
        
        return userFegin.addAddress(request);
    }

    @PostMapping("/updAddress")
    @ApiOperation(value = "修改我的地址")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "addressId", value = "地址id", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "locationAddress", value = "定位地址", required = true, paramType = "String"),
            @ApiImplicitParam(name = "detailedAddress", value = "详细地址", required = true, paramType = "String"),
            @ApiImplicitParam(name = "sort", value = "排序", required = false, paramType = "Integer"),
            @ApiImplicitParam(name = "receiveName", value = "收货人名字", required = true, paramType = "String"),
            @ApiImplicitParam(name = "receivePhone", value = "收货人手机", required = true, paramType = "String"),
    })
    @ApiController(isLogin = true,paramClass =AddressRequest.class)
    public ResultModel updAddress(@RequestAttribute AddressRequest request) {
        
        return userFegin.updAddress(request);
    }

    @PostMapping("/addCollection")
    @ApiOperation(value = "添加收藏")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "itemType", value = "收藏对象类型（1产品，2文章，3企业）", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "itemId", value = "收藏对象ID", required = true, paramType = "Integer"),
    })
    @ApiController(isLogin = true,paramClass =CollectionRequest.class)
    public ResultModel addCollection(@RequestAttribute CollectionRequest request) {
        return userFegin.addCollection(request);
    }

    /**
     * 判断是否已经收藏
     */
    @PostMapping("/getIsCollection")
    @ApiOperation(value = "判断是否已经收藏")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "itemType", value = "收藏对象类型（1产品，2文章，3企业）", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "itemId", value = "收藏对象ID", required = true, paramType = "Integer"),
    })
    @ApiController(isLogin = true,paramClass =CollectionRequest.class)
    public ResultModel<Integer> getIsCollection(@RequestAttribute CollectionRequest request){
        return userFegin.getIsCollection(request);
    }

    @PostMapping("/delAddress")
    @ApiOperation(value = "删除我的地址")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "addressIds", value = "地址ID（逗号隔开）", required = true, paramType = "String"),
    })
    @ApiController(isLogin = true,paramClass =AddressRequest.class)
    public ResultModel delAddress(@RequestAttribute AddressRequest request) {
        
        return userFegin.delAddress(request);
    }

    @PostMapping("/delCollection")
    @ApiOperation(value = "取消收藏")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "itemType", value = "收藏对象类型（1产品，2文章，3企业）", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "itemId", value = "收藏对象ID", required = true, paramType = "Integer"),
    })
    @ApiController(isLogin = true,paramClass =CollectionRequest.class)
    public ResultModel delCollection(@RequestAttribute CollectionRequest request) {
        return userFegin.delCollection(request);
    }

    @PostMapping("/getAddress")
    @ApiOperation(value = "查询我的地址")
    @ApiImplicitParams({})
    @ApiController(isLogin = true,isParam = false)
    public ResultModel getAddress(@RequestAttribute TokenRequest tokenRequest) {
        return userFegin.getAddress(tokenRequest);
    }

    @PostMapping("/getCollection")
    @ApiOperation(value = "查询收藏")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "itemType", value = "收藏对象类型（1产品，2文章，3企业）", required = true, paramType = "Integer"),
    })
    @ApiController(isLogin = true,paramClass =CollectionRequest.class)
    public ResultModel getCollection(@RequestAttribute CollectionRequest request) {
        return userFegin.getCollection(request);
    }

    @PostMapping("/isdefult")
    @ApiOperation(value = "我的地址设置为默认值")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "addressId", value = "地址ID", required = true, paramType = "Integer"),
    })
    @ApiController(isLogin = true,paramClass =AddressRequest.class)
    public ResultModel isdefult(@RequestAttribute AddressRequest request) {
        
        return userFegin.isdefult(request);
    }

    @PostMapping("/getCompanyAllInfo")
    @ApiOperation(value = "查询所有公司信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "companyName", value = "公司名称", paramType = "String"),
    })
    @ApiController(paramClass = CompanyRequest.class)
    public ResultModel getCompanyAllInfo(@RequestAttribute CompanyRequest request){
        return userFegin.getCompanyAllInfo(request);
    }

    @PostMapping("/getDynamicInfo")
    @ApiOperation(value = "查询公司动态")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "dynamicId", value = "动态id", paramType = "Integer"),
            @ApiImplicitParam(name = "companyId", value = "公司id", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "companyName", value = "公司名称", paramType = "Integer"),
            @ApiImplicitParam(name = "cardId", value = "名片id", required = true, paramType = "Integer"),
    })
    @ApiController(isLogin = true,paramClass =DynamicRequest.class)
    public ResultModel<List<DynamicResponse>> getDynamicInfo(@RequestAttribute DynamicRequest request){
        return userFegin.getDynamicInfo(request);
    }

    @PostMapping("/doDynamicThumbs")
    @ApiOperation(value = "给动态/文章点赞")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "dynamicId", value = "动态id", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "cardId", value = "入口名片id", required = true, paramType = "Integer"),
    })
    @ApiController(isLogin = true,paramClass =DynamicRequest.class)
    public ResultModel doDynamicThumbs(@RequestAttribute DynamicRequest request){
        return userFegin.doDynamicThumbs(request);
    }

    @PostMapping("/getWebsiteInfo")
    @ApiOperation(value = "查询公司官网")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "websiteId", value = "官网id", paramType = "Integer"),
            @ApiImplicitParam(name = "companyId", value = "公司id", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "companyName", value = "公司名称", paramType = "Integer"),
    })
    @ApiController(isLogin = true,paramClass =WebsiteRequest.class)
    public ResultModel getWebsiteInfo(@RequestAttribute WebsiteRequest request){
        return userFegin.getWebsiteInfo(request);
    }

    @PostMapping("/selectComment")
    @ApiOperation(value = "查询所有评论/回复")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "dynamicId", value = "动态/文章id", required = true, paramType = "Integer")
    })
    @ApiController(isLogin = true,paramClass =CommentRequest.class)
    public ResultModel selectComment(@RequestAttribute CommentRequest request) {
        return userFegin.selectComment(request);
    }

    @PostMapping("/doComment")
    @ApiOperation(value = "用户评论/回复")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "cardId", value = "用户选择进入名片的入口名片ID", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "dynamicId", value = "动态/文章id", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "parentId", value = "父级ID（评论为0，回复为对应评论ID）", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "text", value = "内容", required = true, paramType = "String"),
    })
    @ApiController(isLogin = true,paramClass =CommentRequest.class)
    public ResultModel doComment(@RequestAttribute CommentRequest request) {
        return userFegin.doComment(request);
    }

    @PostMapping("/delComment")
    @ApiOperation(value = "用户删除评论")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "commentId", value = "评论id", required = true, paramType = "Integer"),
    })
    @ApiController(isLogin = true,paramClass =CommentRequest.class)
    public ResultModel delComment(@RequestAttribute CommentRequest request) {
        return userFegin.delComment(request);
    }

    @PostMapping("/getCompanyRecruit")
    @ApiOperation(value = "查询公司招聘信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "companyId", value = "公司id", required = true, paramType = "Integer"),
    })
    @ApiController(paramClass =CompanyRecruitRequest.class )
    public ResultModel<List<CompanyRecruitResponse>> getCompanyRecruit(@RequestAttribute CompanyRecruitRequest request){
        return userFegin.getCompanyRecruit(request);
    }

    @PostMapping("/addDemand")
    @ApiOperation(value = "用户提交需求信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "companyId", value = "公司id", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "name", value = "姓名", required = true, paramType = "String"),
            @ApiImplicitParam(name = "phone", value = "电话", required = true, paramType = "String"),
            @ApiImplicitParam(name = "cardId", value = "入口名片id", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "text", value = "需求内容", paramType = "String"),
    })
    @ApiController(isLogin = true,paramClass =DemandRequest.class)
    public ResultModel addDemand(@RequestAttribute DemandRequest request){
        return userFegin.addDemand(request);
    }

    @PostMapping("/addFormId")
    @ApiOperation(value = "用户保存formId")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "formId", value = "formId", required = true, paramType = "String"),
            @ApiImplicitParam(name = "type", value = "1:user端,2:crm端", required = true, paramType = "Integer"),
    })
    @ApiController(isLogin = true,paramClass =UserRequest.class)
    public ResultModel<Integer> addFormId(@RequestAttribute UserRequest request){
        return userFegin.addFormId(request);
    }

    @PostMapping("/selectUserCommonList")
    @ApiOperation(value = "查询用户常用语（3.2版本迭代）")
    @ApiController(isLogin = true, paramClass = UserCommonRequest.class)
    public ResultModel<List<UserCommonResponse>> selectUserCommonList(@RequestAttribute UserCommonRequest request) {
        return userFegin.selectUserCommonList(request);
    }

    @PostMapping("/insertUserCommonList")
    @ApiOperation(value = "新增/修改用户常用语（3.2版本迭代）")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "commonId", value = "用户常用语id", paramType = "Integer"),
            @ApiImplicitParam(name = "text", value = "内容", required = true, paramType = "String"),
    })
    @ApiController(isLogin = true, paramClass = UserCommonRequest.class)
    public ResultModel<Boolean> insertUserCommonList(@RequestAttribute UserCommonRequest request) {
        return userFegin.insertUserCommonList(request);
    }

    @PostMapping("/delUserCommonList")
    @ApiOperation(value = "删除用户常用语（3.2版本迭代）")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "commonId", value = "用户常用语id", required = true, paramType = "Integer"),
    })
    @ApiController(isLogin = true, paramClass = UserCommonRequest.class)
    public ResultModel<Boolean> delUserCommonList(@RequestAttribute UserCommonRequest request) {
        return userFegin.delUserCommonList(request);
    }

    @PostMapping("/moveUserCommon")
    @ApiOperation(value = "上下移动用户常用语（3.2版本迭代）")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "commonId", value = "用户常用语id", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "moveType", value = "1上移，2下移", required = true, paramType = "Integer"),
    })
    @ApiController(isLogin = true, paramClass = UserCommonRequest.class)
    public ResultModel<Boolean> moveUserCommon(@RequestAttribute UserCommonRequest request) {
        return userFegin.moveUserCommon(request);
    }
}
